package com.hc.conferencecheck.controller;

import com.hc.conferencecheck.service.ExportExcelService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * 用于导出文件的controller
 */
@RestController
@RequestMapping("/exportExcelController")
public class ExportExcelController {
    @Resource
    private ExportExcelService exportExcelServiceImpl;

    /**
     * 导出指定会议的用户申请记录
     */
    @RequestMapping("/exportAttendRecordInfoByConferenceId")
    public void exportAttendRecordInfoByConferenceId(HttpServletRequest request, HttpServletResponse response) {
        exportExcelServiceImpl.exportAttendRecordInfoByConferenceId(request, response);
    }


    /**
     * 导出用户基础信息
     */
    @RequestMapping("/exportConventionerBaseInfo")
    public void exportConventionerBaseInfo(HttpServletRequest request, HttpServletResponse response) {
        exportExcelServiceImpl.exportConventionerBaseInfo(request, response);
    }


    /**
     * 导出用户申请记录
     */
    @RequestMapping("/exportConventionerAttendRecords")
    public void exportConventionerAttendRecords(HttpServletRequest request, HttpServletResponse response) {
        String conventionerId = request.getParameter("conventionerId");
        //如果有参数，就传入，否则传递空参数
        Map<String, Object> params = new HashMap<>();
        if (conventionerId != null && !conventionerId.equals("")) {
            params.put("conventionerId", conventionerId);
        }


        exportExcelServiceImpl.exportConventionerAttendRecords(params, response);
    }
}
